<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>

<html>
<head>
<title>频道内列表页</title>
<script type="text/javascript">
	var channelList_grid = null;
	$(function() {
		channelList_grid = $("#contentList_grid")
				.ligerGrid(
						{
							title : '内容列表',
							columns : [
										{
											display: '图片', 
											height:100,
											name: 'picture',
											isAllowHide: false, 
											isSort : false,
											render: function (record, rowindex, value, column){
												//alert(value);
												var html ='';
												if(value ==''){
													html='无';
												}else{
													html = '<img src="'+value+'" alt="" class="user_img"  width="100px" height="100px"/>'; 
												}
												return html; 
											}
										},
									{
										display : '标题',
										name : 'title',
										isSort : false,
									},
									{
										display : '超链接',
										name : 'link',
										isSort : false,
										render: function (record, rowindex, value, column){
											//alert(value);
											var html ='';
											if(value ==''){
												html='无';
											}else{
												html = value; 
											}
											return html; 
										}
									},
									{
										display : '创建时间',
										name : 'gmtCreated',
										isSort : false,
										render : function(record, rowindex,
												value, column) {
											return (new Date(value.time))
													.format("yyyy年MM月dd日 hh:mm:ss");
										}
									},
									{
					                	display: '操作', 
					                	name: 'identifier',
					                	isAllowHide: false, 
					                	isSort : false,
										render: function (record, rowindex, value, column){
											//alert(value);
											var html = '<a onclick="deleteContent(\''+ value + '\')" href="javascript:;">删除</a>&nbsp;<a onclick="updateContent(\''+ value + '\')" href="javascript:;">更新</a>&nbsp;'; 
											return html; 
										}
					                }
									],
							pageSize : 30,
							root : 'list',
							record : 'totalRecord',
							url : "/misc/index/channelContentGrid.htm?channel=${channel}",
							width : '99%',
							height : '50%'
						});

	});
	
	
	//删除内容
	function deleteContent(identifier){
		$.post("/misc/index/deleteContent.htm", {
			identifier :identifier
		},function(data){
			if(data=="success"){
				alert("已删除");
				channelList_grid.loadData();
			}
			if(data=="error"){
				alert("删除失败了。");
			}
		});
	
	}
	//更新
	function updateContent(identifier){
		$('#updateContent').load("/misc/index/updateContent.htm?identifier="+identifier+"&type=${type}");
	}
	
</script>
</head>
<body>
	<div id="contentList_grid" style="margin: 0; padding: 0;"></div>
	<div id="updateContent"> </div>
	
</body>
</html>